<template>
  <a-dropdown style="display: inline-block; height: 100%; vertical-align: initial" >
    <span style="cursor: pointer">
      <a-avatar class="avatar" size="small" shape="circle" />
      <a-icon type="user" /> <span>{{currUser.username}}</span>
    </span>
    <a-menu style="width: 150px" slot="overlay" @click="doMenu">
      <a-menu-item key="1">
          <a-icon type="poweroff" />
          <span>退出登录</span>
      </a-menu-item>
    </a-menu>
  </a-dropdown>
</template>

<script>
import { removeToken } from '@/utils/auth';
export default {
  name: 'HeaderAvatar',
  computed: {
    currUser () {
      return this.$store.state.account.user
    }
  },methods: {
  	doMenu(e) {
  	removeToken();
			this.$router.push({ path: '/login' });
  	}
  },
}
</script>

<style lang="less" scoped>
  .avatar{
    margin: 20px 4px 20px 0;
    color: #1890ff;
    background: hsla(0,0%,100%,.85);
    vertical-align: middle;
  }
</style>
